﻿package com.tdzx.adapter;

import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.tdzx.R;

public class PopSortAdapter extends BaseAdapter {
	LayoutInflater factory;
//	public static int selected = 0;
	String sortSelected;
	
	public PopSortAdapter(LayoutInflater factory,String sortSelected) {
		this.factory = factory;
		this.sortSelected = sortSelected;
	}

	@Override
	public int getCount() {
		return sort.length;
	}

	@Override
	public Object getItem(int position) {
		return sort[position];
	}
 
	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if(convertView == null) {
			convertView = factory.inflate(R.layout.list_service_item, null);
		}
		TextView sort_type = (TextView) convertView.findViewById(R.id.sort_type);
		sort_type.setText(sort[position]);
		if(sortSelected.equals(sort[position])) {
			sort_type.setTextColor(Color.parseColor("#F48316"));
//			convertView.setBackgroundResource(R.color.list_item_selected);
		} else {
			sort_type.setTextColor(Color.BLACK);
			convertView.setBackgroundDrawable(null);
		}
		/*if(position == selected) {
			sort_type.setTextColor(Color.CYAN);
		} else {
			sort_type.setTextColor(Color.BLACK);
		}*/
		return convertView;
	}

//	String[] sort = new String[]{"默认排序","距离最近","人气排序","总体评价排序","费用低到高","费用高到低"};
	String[] sort = new String[]{"距离最近","人气排序","总体评价排序","费用低到高","费用高到低"};
}
